#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<stack>
using namespace std;
//从尾到头打印链表
struct ListNode
{
	int m_nKey;
	ListNode* next;
};
//方法一，使用栈
void printList(ListNode* pHead)
{
	stack<ListNode*>nodes;
	ListNode* pNode = pHead;
	while (pNode != nullptr)
	{
		nodes.push(pHead);
		pNode = pNode->next;
	}
	while (!nodes.empty())
	{
		pNode = nodes.top();
		cout << pNode->m_nKey << "   ";
		nodes.pop();
	}
}
//方法二 使用递归
void printL(ListNode* pHead)
{
	if (pHead != nullptr)
	{
		if (pHead->m_nKey != NULL)
		{
			printL(pHead->next);
		}
		cout << pHead->m_nKey << "  ";
	}
}